package win.acfelis.tools;

/**
 * Created by ganlu on 2017/12/27.
 */
public class ApiResult<T> {
    private boolean succ;
    private int code;
    private String msg;
    private T data;

    public boolean isSucc() {
        return succ;
    }

    public void setSucc(boolean succ) {
        this.succ = succ;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ApiResult failure(int code, String message) {
        this.succ = false;
        this.code = code;
        this.msg = message;
        return this;
    }

    public ApiResult<T> success(int status, String message, T data) {
        this.succ = true;
        this.code = status;
        this.msg = message;
        this.data = data;
        return this;
    }

    public ApiResult success(int status, String message) {
        this.succ = true;
        this.code = status;
        this.msg = message;
        return this;
    }
}
